cmake_minimum_required(VERSION 3.31)
project(test-makefile VERSION 1.0 DESCRIPTION "An example project with CMake")

include(FetchContent)
#set(CMAKE_FETCHCONTENT_BASE_DIR "${CMAKE_SOURCE_DIR}/third_party")

#强制编译器必须支持C++20
set(CMAKE_CXX_STANDARD 20)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

FetchContent_Declare(
        nanomodbus
        GIT_REPOSITORY https://github.com/debevv/nanoMODBUS
        GIT_TAG master # or the version you want
        GIT_SHALLOW TRUE
)

FetchContent_MakeAvailable(nanomodbus)

add_subdirectory(zhm)

# 源文件目录搜索
aux_source_directory(./src DIR_SRCS)
add_executable(${PROJECT_NAME} ${DIR_SRCS} mongoose/mongoose.c src/client.cpp)

target_include_directories(${PROJECT_NAME} PRIVATE ./include ./mongoose)

if (WIN32)
    target_link_libraries(${PROJECT_NAME} zhm nanomodbus ws2_32)
else ()
    target_link_libraries(${PROJECT_NAME} zhm nanomodbus)
endif ()